/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mbean.admin.attendance;

import mbean.admin.customer.*;
import mbean.AbstractMB;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import model.entity.Attendance;
import model.entity.Customer;
import org.omnifaces.util.Faces;
import org.primefaces.model.LazyDataModel;
import service.InterfaceServiceLocal;
import utils.PageDateModel;
import utils.QueryStr;

/**
 *
 * @author dingnangen
 */
@Named(value = "attendanceMB")
@SessionScoped
public class AttendanceMB extends AbstractMB implements Serializable {

    @EJB(beanName = "AttendanceManager")
    private InterfaceServiceLocal attendanceManager;

    private LazyDataModel<Attendance> items = null;

    private Attendance currentAttendance;

    private Date attendanceselection = new Date();
    private final List<String> pList = new ArrayList();
    private final List<Date> datepList = new ArrayList();

    /**
     * Creates a new instance of CustomerMB
     */
    public AttendanceMB() {
    }

    /**
     * 初始化
     */
    public void init() {
        if (Faces.isPostback()) {
            System.out.println("isPostback");
            return;
        }
        if (pList.size() == 0) {
            pList.add("attendancedate");
        }
    }

    public LazyDataModel<Attendance> getItems() {
        datepList.clear();
        datepList.add(attendanceselection);
        if (items == null) {
            QueryStr qs = new QueryStr("Attendance", 0, pList);
            items = new PageDateModel<Attendance>(qs, attendanceManager, datepList);

        }
        return items;
    }

    public void setItems(LazyDataModel<Attendance> items) {
        this.items = items;
    }

    public Date getAttendanceselection() {
        return attendanceselection;
    }

    public void setAttendanceselection(Date attendanceselection) {
        this.attendanceselection = attendanceselection;
    }

}
